package com.service.device;

import com.common.ErrorCodeEnum;
import com.common.emums.DataStatus;
import com.common.exception.BusinessException;
import com.common.utils.StringUtils;
import com.core.springSecurity.common.SecurityUtils;

import com.dao.secondary.device.DevicePmdVersionInfoMapper;
import com.github.pagehelper.Page;
import com.model.domain.device.GetDevicePmdVersionInfoDO;
import com.model.pojo.device.DevicePmdVersionInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;



/**
 * @Author: zql
 * @Description: PMD播种机版本号信息管理服务
 * @Data: 2023-07-16
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DevicePmdVersionInfoService {
    private final DevicePmdVersionInfoMapper devicePmdVersionInfoMapper;

    public List<DevicePmdVersionInfo> getPageList(GetDevicePmdVersionInfoDO getDevicePmdVersionInfoDO){
        PageHelper.clearPage();
        PageHelper.startPage(getDevicePmdVersionInfoDO.getPage(),getDevicePmdVersionInfoDO.getPageSize(),getDevicePmdVersionInfoDO.getSortRow()+getDevicePmdVersionInfoDO.getSortOrder());
        return devicePmdVersionInfoMapper.selectList(getDevicePmdVersionInfoDO);
    }

    public int save(DevicePmdVersionInfo info){
        info.setCreateTime(new Date());
        return devicePmdVersionInfoMapper.insertSelective(info);
    }
    public int update(DevicePmdVersionInfo info){
        return devicePmdVersionInfoMapper.updateByPrimaryKeySelective(info);
    }

    public void delete(Long id){
        devicePmdVersionInfoMapper.deleteByPrimaryKey(id);
    }
    public DevicePmdVersionInfo getById(Long id){
        return devicePmdVersionInfoMapper.selectByPrimaryKey(id);
    }
}
